//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by liyue on 15/11/8.
//  Copyright © 2015年 李越. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {

    var userLogin = UserAccountViewModel().userLogin
    var visitorLoginView : VisitorLoginView?
    
    
    override func loadView() {
        
        userLogin ? super.loadView() : loadVisitorView()
        //super.loadView() //效果与之前一样
        
    }
    
    private func loadVisitorView() {
        
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.visitorDelegate = self
        view = visitorLoginView
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
        
        //UINavigationBar.appearance().tintColor = UIColor.orangeColor()
    }
    
    func visitorWillLogin() {
        
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorWillRegister() {
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        

    }
    
}
